iT邦幫忙

2024 iThome 鐵人賽

DAY 3
0

Day3 Environment2

今天來設定一下資料庫(主要是把 dvdrental 放到 postgres 裡面)

Getting Started

這邊是我自己的作法,可能不是 best practice,但目前作為練習可以 work

  1. 先能進入 psql
sudo -i -u postgres psql # 可以直接進入 psql

我們目前無法直接用正常指令登進去,like

# postgres 預設帳號 postgres, 密碼 postgres

psql -U postgres -W # postgres

# 這樣會報以下錯誤
# psql: error: FATAL:  Peer authentication failed for user "postgres"

``
2. 修改一下設定檔, 讓他可以正常用 password 進入

sudo vim /etc/postgresql/14/main/pg_hba.conf

# 將以下這一行改成
# Database administrative login by Unix domain socket
local   all             postgres                                peer

改成
local   all             postgres                                password

# 然後 :wq! 存檔退出
  1. 重啟一下 psql,這樣設定才會生效
sudo systemctl restart postgresql
  1. 最後正常登入 postgres
psql -U postgres -W # 密碼輸入: postgres

上一篇
Day2 環境設定1
下一篇
Day4 準備資料
系列文
我獨自升級之資料庫從入門到中階6
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言